<?php

namespace app\nideshop\controller;

use think\Db;
use app\nideshop\service\Token;

/**
 * 
 */
class Brand extends Base
{
    protected $datas;

    public function listAction()
    {
        $this->datas = $this->params;
        $page = 1;
        $size = 10;
        if (isset($this->datas['page']))
        {
            $page = $this->datas['page'];
        }
        if (isset($this->datas['size']))
        {
            $size = $this->datas['size'];
        }
        $data = Db::name('brand')
        ->field('id,name,floor_price,app_list_pic_url')
        ->paginate($size, false, ['page' => $page]);
        return json([
            'errno' => 0,
            'errmsg' => '成功',
            'data' => [
                'count' => $data->total(),
                'totalPages' => $data->lastPage(),
                'pageSize' => (int) $size,
                'currentPage' => $page,
				'data' => $data->items()
            ]
        ]);
    }

    public function detailAction()
    {
        $this->datas = $this->params;
        $id = $this->datas['id'];
        $data = Db::name('brand')
        ->where('id', $id)
        ->find();

        return json([
            'errno' => 0,
            'errmsg' => '成功',
            'data' => [
                'brand' => $data
            ]
        ]);
    }
}
